package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from sky_take_out.dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);
    @AutoFill(value= OperationType.INSERT)
    void insert(Dish dish);
    @Select("select * from sky_take_out.dish where id=#{id}")
    Dish getById(Long id);
@Delete("delete from sky_take_out.dish where id=#{id}")
    void deteteById(Long id);
@AutoFill(value=OperationType.UPDATE)
    void update(Dish dish);


    List<Dish> list(Dish dish);
    @Update("update sky_take_out.dish set status=#{status},id=#{id}")
    void startOrStop(Integer status, Long id);

    Integer countByMap(Map map);
}


